package cn.tedu.yl.root.controller;

import cn.tedu.yl.base.response.JsonResult;
import cn.tedu.yl.register.pojo.dto.RegisterQuery;
import cn.tedu.yl.register.pojo.dto.RegisterSaveParam;
import cn.tedu.yl.register.pojo.vo.RegisterVO;
import cn.tedu.yl.root.mapper.RootMapper;
import cn.tedu.yl.root.pojo.dto.RootQuery;
import cn.tedu.yl.root.pojo.dto.RootSaveParam;
import cn.tedu.yl.root.pojo.entity.Root;
import cn.tedu.yl.root.pojo.vo.RootVO;
import cn.tedu.yl.root.service.RootService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/root")
public class RootController {
    @Autowired
    private RootService rootService;
    @Qualifier("rootMapper")
    @Autowired
    private RootMapper rootMapper;

    @PostMapping("save")
    public JsonResult save(RootSaveParam rootSaveParam){
        rootService.save(rootSaveParam);
        return JsonResult.ok("操作成功");
    }

    @GetMapping("select")
    public JsonResult select(RootQuery rootQuery){
        log.info("查询参数:{}",rootQuery);
        List<RootVO> list = rootService.select(rootQuery);
        return JsonResult.ok(list);
    }
}
